#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
int c,T,n,m;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("oi.in","r",stdin);
	freopen("oi.out","w",stdout);
	cin>>c>>T;
	while(T--)
	{
		cin>>n>>m;
		int trash;
		for(int i=1;i<=m;i++)cin>>trash>>trash;
		cout<<-(2*n-2)<<' ';
		int jc=1;
		for(int i=1;i<=n;i++)jc=1ll*jc*i%mod;
		cout<<jc<<'\n';
	}
	return 0;
}

